From: Pablo Neira Ayuso Date: Sat, 2 Jul 2022 02:16:30 +0000 (+0200) Subject: netfilter: nf_tables: stricter validation of element data X-Git-Tag: archive/raspbian/5.10.127-2+rpi1^2~27 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/%22bookmarks:/?a=commitdiff_plain;h=f6d643f2a64f30520b80a1fbc89b4d5e9f619ae7;p=linux.git netfilter: nf_tables: stricter validation of element data Origin: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit?id=0a5e36dbcb448a7a8ba63d1d4b6ade2c9d3cc8bf Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2022-34918 commit 7e6bc1f6cabcd30aba0b11219d8e01b952eacbb6 upstream. Make sure element data type and length do not mismatch the one specified by the set declaration. Fixes: 7d7402642eaf ("netfilter: nf_tables: variable sized set element keys / data") Reported-by: Hugues ANGUELKOV Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman Gbp-Pq: Topic bugfix/all Gbp-Pq: Name netfilter-nf_tables-stricter-validation-of-element-d.patch --- diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 3c17fadaab5..e5622e925ea 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -4886,13 +4886,20 @@ static int nft_setelem_parse_data(struct nft_ctx *ctx, struct nft_set *set, struct nft_data *data, struct nlattr *attr) { + u32 dtype; int err; err = nft_data_init(ctx, data, NFT_DATA_VALUE_MAXLEN, desc, attr); if (err < 0) return err; - if (desc->type != NFT_DATA_VERDICT && desc->len != set->dlen) { + if (set->dtype == NFT_DATA_VERDICT) + dtype = NFT_DATA_VERDICT; + else + dtype = NFT_DATA_VALUE; + + if (dtype != desc->type || + set->dlen != desc->len) { nft_data_release(data, desc->type); return -EINVAL; }